library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0 ✔ purrr 1.0.1
## ✔ tibble 3.1.8 ✔ dplyr 1.1.0
## ✔ tidyr 1.3.0 ✔ stringr 1.5.0
## ✔ readr 2.1.3 ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
bike_sharing <- read_csv("~/Downloads/bikesharing.csv")
## Rows: 731 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): season, month, weekday, weather
## dbl (7): year, temperature_F, casual, registered, count, humidity, windspeed
## lgl (2): holiday, workingday
## date (2): date, date_noyear
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
bike_sharing %>%
mutate(new_col = count/temperature_F) %>%
ggplot(aes(date, new_col)) +
geom_point()
bike_sharing %>%
ggplot(aes(weather, fill=weekday)) +
geom_bar(position="dodge")
bike_sharing %>%
ggplot(aes(weekday, fill=weather)) +
geom_bar(position="dodge")
bike_sharing %>%
ggplot(aes(temperature_F)) +
geom_histogram(fill="dodgerblue")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
ggplot(aes(temperature_F, fill=season)) +
geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
ggplot(aes(temperature_F, fill=season)) +
geom_histogram() +
facet_wrap(~season)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
ggplot(aes(temperature_F, fill=season)) +
geom_histogram() +
geom_freqpoly() +
facet_wrap(~season)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
ggplot(aes(temperature_F, color=season)) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
filter(season == "winter" | season == "summer") %>%
ggplot(aes(temperature_F, color=season)) +
geom_freqpoly()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
bike_sharing %>%
filter(season == "winter" | season == "summer") %>%
ggplot(aes(temperature_F, color=season)) +
geom_density()
bike_sharing %>%
ggplot(aes(temperature_F, color=season)) +
geom_density()
bike_sharing %>%
ggplot(aes(temperature_F, color=season)) +
geom_density() +
labs(title = "Temperature by season")
bike_sharing %>%
ggplot(aes(season, humidity)) +
geom_point(color = "dodgerblue")
bike_sharing %>%
ggplot(aes(season, humidity)) +
geom_jitter(color = "dodgerblue")
bike_sharing %>%
ggplot(aes(season, humidity)) +
geom_boxplot()
bike_sharing %>%
ggplot(aes(season, humidity)) +
geom_jitter() +
geom_boxplot()
bike_sharing %>%
ggplot(aes(season, humidity, fill=weather)) +
geom_boxplot()
## Vignette 6
bike_sharing %>%
ggplot(aes(date, count)) +
geom_point()
bike_sharing %>%
ggplot(aes(date_noyear, count)) +
geom_point()
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year)) +
geom_point()
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year)) +
geom_line()
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year, group=year)) +
geom_line()
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year, group=year)) +
geom_line() +
geom_point()
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year, group=year)) +
geom_line() +
geom_smooth()
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
bike_sharing %>%
ggplot(aes(date_noyear, count, color=year, group=year)) +
geom_line() +
geom_smooth() +
labs(title="number of riders by date", y = "number of riders", x = "date")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
starwars %>%
ggplot(aes(homeworld)) +
geom_bar(fill="dodgerblue")
starwars %>%
group_by(homeworld) %>%
summarize(count=n()) %>%
filter(count > 1) %>%
ggplot(aes(count, homeworld)) +
geom_bar(stat = "identity", fill="dodgerblue")
starwars %>%
drop_na(homeworld) %>%
group_by(homeworld) %>%
summarize(count=n()) %>%
filter(count > 1) %>%
ggplot(aes(count, homeworld)) +
geom_bar(stat = "identity", fill="dodgerblue")
starwars %>%
drop_na(homeworld) %>%
group_by(homeworld) %>%
summarize(count=n()) %>%
filter(count > 1) %>%
ggplot(aes(count, reorder(homeworld, count))) +
geom_bar(stat = "identity", fill="dodgerblue") +
labs(title="Frequency of homeworld in Star Wars", y = "homeworld")
starwars %>%
ggplot(aes(species)) +
geom_bar()
starwars %>%
group_by(species) %>%
summarize(count = n()) %>%
ggplot(aes(species, count)) +
geom_bar(stat="identity")
starwars %>%
group_by(species) %>%
summarize(count = n()) %>%
filter(count > 1) %>%
ggplot(aes(species, count)) +
geom_bar(stat="identity")
starwars %>%
group_by(species) %>%
summarize(count = n()) %>%
filter(count > 1) %>%
ggplot(aes(count, species)) +
geom_bar(stat="identity")
starwars %>%
drop_na(homeworld) %>%
drop_na(species) %>%
group_by(species) %>%
summarize(count = n()) %>%
filter(count > 1) %>%
ggplot(aes(count, reorder(species, count))) +
geom_bar(stat="identity")